#ifndef _LED_H_
#define _LED_H_

#include "Global.h"

#define P_LED1      RB2
#define P_LED2      RB3
#define P_LED3      RB4
#define P_LED4      RB5
#define P_LED5      RB6
#define P_LED6      RB7

#define OPEN(led)   P_##led = LOW
#define CLOSE(led)  P_##led = HIGH

#define LED1_ON     0x01
#define LED2_ON     0x02
#define LED3_ON     0x04
#define LED4_ON     0x08
#define LED5_ON     0x10
#define LED6_ON     0x20
#define LED_ALL_ON  0x3F
#define LED_ALL_OFF 0x00

// extern uint8 RLedBuf;
// void initLED(void);
// void LedMain(void);
// void LedSet(uint8 mode, uint8 tm_on, uint8 tm_off, uint8 loop);
// void LedReset(void);

typedef struct 
{
    uint8 LoopSec1;
    uint8 LoopSec2;
    uint8 OnTimeSec1;
    uint8 OnTimeSec2;
    uint8 Interval;
}Typedef_LED_FLASH;


enum
{
    LED_SCENE_IDLE,
    LED_SCENE_BREATHING = 1,
    LED_SCENE_FADEOUT,
    LED_SCENE_FADEIN,
    LED_SCENE_LOADING,
    LED_SCENE_FLASH,
};

extern uint8 LoopEN;

#define _SCENE_LOADING_CW_      (1)         //---- 0-逆时针 1-顺时针 ----//
#define _SCENE_PERIOD_TIME_     (1000ul/6)  //---- 旋转周期 ----//

#define MIN_BREATH_DUTY         2
#define SPEED_FADEIN_TIME       22
#define SPEED_FADEOUT_TIME      22
#define SPEED_BREATH_TIME       22

void LedScene_Loading(void);
void LedScene_Breathing(void);
void LedScene_FadeOut(void);
void LedScene_FadeIn(void);
void Led_Main(void);
void Led_SwitchScene(uint8 scene);
void LedScene_Flash(void);
void LedScene_SetFlash(uint8 sec1_times, uint8 sec2_times, uint8 sec1_on_time, uint8 sec2_on_time, uint8 interval);
uint8 CheckAllLed(uint8 duty);

#endif
